<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>变量案例</title>
</head>
<body>
<h1>交换两个变量的值</h1>
<script type="text/javascript">
  //交换两个变量的值
  var number1 = 100;
  var number2 = 200;

  //方法1：使用中间变量
  // var number3 = number1;
  // number1 = number2;
  // number2 = number3;
  //方法2：使用算术运算
  number1 = number1 + number2;
  number2 = number1 - number2;
  number1 = number1 - number2;

  //代码调试方法（输出变量）
  //1.alert弹框：浏览器页面弹框(有多个alert时，从上到下依次弹出)
  // alert("number1=" + number1 + ",number2=" + number2);
  //2.console.log();浏览器console控制台（有多个console.log时，按顺序从上倒下一次输出）
  // console.log("number1=" + number1 + ",number2=" + number2)
  //3.document.write();直接在浏览器页面打印出结果
  document.write("number1=" + number1 + ",number2=" + number2);
</script>
</body>
</html>